/**
 * 工作线程中的 performace.now() 反应的是线程开始后到执行是的时间戳
 */
self.onmessage = (e) => {
  let task_start = performance.now();
  console.log(`worker 任务开始时间：${task_start}`);

  for(let i = 0; i < 1000000; i += 1) {
    let random = Math.random() * 100;
  }

  let task_end = performance.now();
  console.log(`worker 任务结束时间：${task_end}`);

  self.postMessage({
    task: 'Some worker task',
    start_time: task_start + performance.timeOrigin,
    end_time: task_end + performance.timeOrigin
  })
}